package com.ryskoo.catering.orderlog.repository;

import com.ryskoo.catering.orderlog.domain.OrderLogPO;
import com.ryskoo.framework.core.repository.BasicJPAImpl;
import com.ryskoo.framework.core.utils.ReflectHelper;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class OrderLogJPAImpl extends BasicJPAImpl<OrderLogPO> implements IOrderLogRepository {
    @Override
    public List<OrderLogPO> getLogListByOrderUuid(String orderUuid) {
        String hql = "select o" + getMultiSelect() + " from "
                + ReflectHelper.getModelClass(this.getClass()).getName()
                + " o " + getMultiModel() + " where orderUuid=:orderUuid"
                + " order by o.createTime desc";

        Query q = getH4Session().createQuery(hql);
        q.setString("orderUuid", orderUuid);

        return q.list();
    }
}
